// Package trip_rider_log 模型
package trip_rider_log

import (
	// "gitee.com/sweetsunnyflower/carpooling-server-go/pkg/logger"
	"gitee.com/sweetsunnyflower/carpooling-server-go/app/models"
	"gitee.com/sweetsunnyflower/carpooling-server-go/pkg/database"
)

// 订单操作记录
type TripRiderLog struct {
	models.BaseModel
	TripRiderId uint64 `gorm:"column:trip_rider_id" db:"trip_rider_id" json:"trip_rider_id" form:"trip_rider_id"` //订单ID
	Action      string `gorm:"type:varchar(255)" db:"action" json:"action" form:"action"`                         //行为：比如修改行程，修改价格等
	UserType    uint8  `gorm:"column:user_type" db:"user_type" json:"user_type" form:"user_type"`                 //行为人类型1：司机，2：乘客
	Log         string `gorm:"column:log" db:"log" json:"log" form:"log"`                                         //行为内容，代码中自定义结构
	models.CommonTimestampsField
}

func (tripRiderLog *TripRiderLog) Create() {
	database.DB.Create(&tripRiderLog)
}

func (tripRiderLog *TripRiderLog) Save() (rowsAffected int64) {
	result := database.DB.Save(&tripRiderLog)
	return result.RowsAffected
}

func (tripRiderLog *TripRiderLog) Delete() (rowsAffected int64) {
	result := database.DB.Delete(&tripRiderLog)
	return result.RowsAffected
}
